package Servlets;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet("/courseAdmin")
public class courseAdmin extends HttpServlet {
	private static final long serialVersionUID = 1L;


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		if(request.getParameter("delete")!=null)
		{
			
			String cName = request.getParameter("courseName");
			String cSection = request.getParameter("courseSection");
			System.out.println("Admin Course -> Delete "+cName+" "+cSection);
			//DELETE ACTION
		}
		else
		{
			if(request.getParameter("edit")!=null)
			{
				String cName = request.getParameter("courseName");
				String cSection = request.getParameter("courseSection");
				String cTimings = request.getParameter("courseTimings");
				String cLocation = request.getParameter("courseLocation");
				
				request.setAttribute("cname", cName);
				request.setAttribute("csection", cSection);
				request.setAttribute("ctiming", cTimings);
				request.setAttribute("clocation", cLocation);
				//EDIT ACTION
				System.out.println("Admin Course -> Edit "+cName+" "+cSection);
				
				RequestDispatcher rd=getServletContext().getRequestDispatcher("/View/courseInfo.jsp");
				rd.forward(request, response);
			}
		}
	}

}
